import Vue from 'vue'
import Router from 'vue-router'
// import store from '../store'
import Layout from '../components/layout/Layout'
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/components/user/login/login'), hidden: true },
  // { path: '/404', component: () => import('@/components/error/noControl/noControl'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/spaceControl',
    name: 'admin',
    hidden: true,
    children: [{
      path: '/admin',
      component: () => import('@/components/admin/adminControl/index')
    }]
  },
  {
    path: '/statisticalAnalysis',
    component: Layout,
    redirect: '/statisticalAnalysis/userAnalysis',
    name: 'statisticalAnalysis',
    meta: { title: '统计分析', icon: 'example' },
    children: [
      {
        path: 'userAnalysis',
        name: 'userAnalysis',
        component: () => import('@/components/admin/statisticalAnalysis/userAnalysis/userAnalysis'),
        meta: { title: '用户分析', icon: 'table' }
      },
      {
        path: 'orderAnalysis',
        name: 'orderAnalysis',
        component: () => import('@/components/admin/statisticalAnalysis/orderAnalysis/orderAnalysis'),
        meta: { title: '订单分析', icon: 'table' }
      },
      {
        path: 'spaceAnalysis',
        name: 'spaceAnalysis',
        component: () => import('@/components/admin/statisticalAnalysis/spaceAnalysis/spaceAnalysis'),
        meta: { title: '用户分析', icon: 'table' }
      }
    ]
  },

  {
    path: '/adminControl',
    component: Layout,
    redirect: '/adminControl/userControl',
    name: 'adminControl',
    meta: { title: '管理', icon: 'example' },
    children: [
      {
        path: 'adminControl/userControl',
        name: 'userControl',
        component: () => import('@/components/admin/adminControl/userControl/userControl'),
        meta: { title: '用户管理', icon: 'form' }
      },
      {
        path: 'adminControl/userControl/seeAllrecord',
        name: 'userControl/seeAllrecord',
        component: () => import('@/components/admin/adminControl/userControl/seeAllrecord'),
        hidden: true,
        meta: { title: '用户消费详情' }
      },
      {
        path: 'adminControl/spaceControl',
        name: 'spaceControl',
        component: () => import('@/components/admin/adminControl/spaceControl/spaceControl'),
        meta: { title: '空间管理', icon: 'form' }
      },
      {
        path: 'adminControl/spaceControl/addSpace',
        name: 'spaceControl/addSpace',
        component: () => import('@/components/admin/adminControl/spaceControl/addSpace'),
        hidden: true,
        meta: { title: '添加空间' }
      },
      {
        path: 'adminControl/spaceControl/spaceDetail',
        name: 'spaceControl/spaceDetail',
        component: () => import('@/components/admin/adminControl/spaceControl/spaceDetail'),
        hidden: true,
        meta: { title: '空间详情' }
      },
      {
        path: 'adminControl/spaceControl/incomeDrtail',
        name: 'spaceControl/incomeDrtail',
        component: () => import('@/components/admin/adminControl/spaceControl/incomeDrtail'),
        hidden: true,
        meta: { title: '收入情况' }
      },
      {
        path: 'adminControl/orderControl',
        name: 'orderControl',
        component: () => import('@/components/admin/adminControl/orderControl/orderControl'),
        meta: { title: '订单管理', icon: 'form' }
      },
      {
        path: 'adminControl/orderControl/orderDetail',
        name: 'orderControl/orderDetail',
        component: () => import('@/components/admin/adminControl/orderControl/orderDetail'),
        hidden: true,
        meta: { title: '订单详情' }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
